<?php

/**
 * Description of Db
 *
 * @author Clive
 */
class db {

    static private $dbconn;
    protected $search, $pageinfo, $order;

    public static function getInstance() {
        $dbconfig = import('config.dbconfig', false, app::$APP_ROOTDIR);
        $dbconf = $dbconfig['default'];
        if ($dbconf['dbdriver'] == 'mysql') {
            if (!self::$dbconn) {
                self::$dbconn = mysql_connect($dbconf['dbhost'] . ':' . $dbconf['dbport'], $dbconf['dbuser'], $dbconf['dbpwd']) or die(mysql_error());
                mysql_query('use `' . $dbconf['dbname'] . '`', self::$dbconn);
                mysql_query("set names '" . $dbconf['dbcharset'] . "'", self::$dbconn);
            }
            return(new mysql(self::$dbconn));
        } else {
            die('暂不支持mysql以外的SQL查询引擎！');
        }
    }

}